package cn.itsource.hrm.controller;

import cn.itsource.hrm.service.IImageValidateCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/imgCode")
public class ImageValidateCodeController {

    @Autowired
    private IImageValidateCodeService imageValidateCodeService;
    /**
     * 通过前端传入key生成验证码存储redis，并把验证码写入图片以base64加密作为字符串返回。
     * @param key
     * @return
     */
    @GetMapping("/{key}")
    public String generateImgCode(@PathVariable(name = "key")String key){
        return imageValidateCodeService.generateImgCode(key);
    }
}
